<?php


namespace app\bock\type;


class Point
{
    /**
     * 所在行
     * @var int
     */
    protected $row;


    /**
     * 所在列
     * @var int
     */
    protected $col;


    /**
     * Point constructor.
     * @param $row
     * @param $col
     */
    public function __construct($row, $col)
    {
        $this->setRow($row);
        $this->setCol($col);
    }

    /**
     * @param int $row
     */
    public function setRow($row)
    {
        $this->row = $row;
    }

    /**
     * @param int $col
     */
    public function setCol($col)
    {
        $this->col = $col;
    }

    /**
     * @return int
     */
    public function getRow()
    {
        return $this->row;
    }

    /**
     * @return int
     */
    public function getCol()
    {
        return $this->col;
    }

    /**
     * 计算返回一个新的点
     * @param Point $point
     * @return Point
     */
    public function addPoint(Point $point)
    {
        $row = $this->getRow() + $point->getRow();
        $col = $this->getCol() + $point->getCol();

        return new self($row, $col);
    }
}